@import url('https://fonts.googleapis.com/css2?family=Asap+Condensed:ital@1&display=swap');

h1, h2, h3, h4 {font-family: 'Lato', sans-serif;
    font-weight: bold}

body {font-family: 'Oswald', sans-serif;;
     background-color: #ebfafaq} 

Introduction

In this HTML I tried to compare and contrast a few aspects of music in the last decades. The Playlist that I used for this assignment is called Pure Rock And Roll. Its a playlist of over a hundred rock songs from the 1960s to 2022. I tried to choose a playlist that could be representative of more popular genres but I was unable to find any that had a timeline like this playlist. In this HTML I tried to focus on how the music has changed through out the years by making a few plots.

song_data <- fromJSON("rock.json") %>%
  
# I used mutate() function to translate the specific release_date of songs (e.g. 1991-09-26) into just 4 digits (1991)
  mutate(year_published = str_sub(release_date, 1, 4) %>% as.numeric()) 

Louder Is Better?

Loudness is basically how loud a song is. There is concept called loudness war which refers to how songs keep getting louder over the years due to over compression, this is a technique to make music more exciting and give the illusion of better music to the listener. In the plot below we see how there is a significant increase in loudness after 1990s, the bigger the negative the number is (e.g. -15 db ) the quitter the song is and the smaller loudness scores refers to louder songs and there seems to be a liner trend in the music loudness over the years, This could be due to the fact that my data only includes Rock songs which is known for loud and distorted riffs and licks but I assume this trend would be similar in most of the other popular genres nowadays as well. I used geom_step() function to make this plot as it has the data has a gradual increase in loudness scores.

    ggplot(song_data) +
    geom_step(aes(x = loudness, y = year_published),
              colour = "#66ccff",
              size = 0.6) +
    theme(panel.background = element_rect(fill = 
"#f5f5f0")) +
  guides(colour = "none",
         fill = "none") +
  labs(title = "Loudness",
       subtitle = "A Plot Of How Song Loudness Has Changed overtime",
       x = "Music Loudness (In db)",
       y = "Year Published",
       caption = "Data source: Spotify pure rock and roll playlist ")

Songs Are Getting Shorter!

I used a dot plot below to show the trend of song lengths over the past 60 years. I used some gganimate functions on the graph on the bottom to add some animation to my HTML however I decided keep a smaller version of my original plot in case on the top. For making this plot I simply used the geom_point() function and I used a few other functions on the graph on the bottom such as transition_time(), shadow_wake and shadow_mark() to add the animation. This plot shows the song duration of each song based on their release date. This starts at round 1960s which is when that songs were too short and start gradually getting longer until around 1990s which song are the longest however songs start to get shorter again around the 2000s, this could be because peoples attention span has gotten shorter as well.

song_durations <- song_data %>%
  
  group_by(year_published) %>%
  summarise(song_lenght = duration_ms / 1000 / 60)

    ggplot(song_durations) +
    geom_point(aes(x = year_published, y = song_lenght),
              colour = "#8080ff",
              size = 1,
              alpha = 0.75) + 

          theme(panel.background = element_rect(fill = 
"#f5f5f0")) +
  guides(colour = "none",
         fill = "none") +
      
  labs(title = "Song Lenght Changes",
       subtitle = "A Plot Of How Song Duration Has Changed overtime",
       x = "Year published",
       y = "song lenght (in minutes)",
       caption = "Data source: Spotify pure rock and roll playlist ") +
      scale_y_continuous(limits = c(2, 9),
                         breaks = seq(2, 9, 1))

song_durations <- song_data %>%
  
  group_by(year_published) %>%
  summarise(song_lenght = duration_ms / 1000 / 60)

    ggplot(song_durations) +
    geom_point(aes(x = year_published, y = song_lenght),
              colour = "#8080ff",
              size = 1) + 

          theme(panel.background = element_rect(fill = 
"#f5f5f0")) +
  guides(colour = "none",
         fill = "none") +
      
  labs(title = "Song Lenght Changes",
       subtitle = "A Plot Of How Song Duration Has Changed overtime",
       x = "Year published",
       y = "song lenght (in minutes)",
       caption = "Data source: Spotify pure rock and roll playlist ") +
      scale_y_continuous(limits = c(2, 9),
                         breaks = seq(2, 9, 1)) +
      
      
      transition_time(year_published) +
      
      view_follow(fixed_y = TRUE) +
      
      shadow_wake(wake_length = 0.2, alpha = FALSE) +
      
      shadow_mark(alpha = 0.4, size = 0.7) 

## Did Tempo Stayed The Same Over The Years?

I used geom_smooth() function to create the tempo plot below but first I made a new data frame called tempo_songs using group_by(), summaeise() and filter() functions. I also tired to add a new variable called decades which would split all the years into decades using case_when() function but that did not really workout as we were only thought how to use case_when () function on the categorical variables. The plot below shows how the tempo of songs has changed over the years and there is a trend of increase in tempo again here

tempo_songs <- song_data %>%
   mutate(decades = case_when(year_published ==1990 : 1999 ~ "90s",
                                  year_published==1980 : 1989 ~ "80s",
                                  year_published==1970 : 1979 ~ "70s",
                                  year_published==1960 : 1969 ~ "60s",
                                  year_published==2000 : 2010 ~ "2000s",
                                  year_published==2010 : 2022 ~ "current",
                                  TRUE ~ "other")) %>%
  
  group_by(year_published) %>%
  arrange(desc(tempo)) %>%
  filter(year_published > 1960) %>%
  slice(1 : 2)


tempo_songs %>%
  select(year_published, tempo)
## # A tibble: 81 x 2
## # Groups:   year_published [48]
##    year_published tempo
##             <dbl> <dbl>
##  1           1964 139. 
##  2           1964 137. 
##  3           1965  96.7
##  4           1967 115. 
##  5           1967  89.8
##  6           1968 146. 
##  7           1968 113. 
##  8           1969 133. 
##  9           1969 108. 
## 10           1970 121. 
## # ... with 71 more rows
ggplot(tempo_songs) +
    geom_smooth(aes(x = tempo, y = year_published),
                color = "#ffa64d") +
      theme(panel.background = element_rect(fill = 
"#f5f5f0")) +
  guides(colour = "none",
         fill = "none") +
  scale_x_continuous(limits = c(87, 192),
                     breaks = seq(87, 192, 15)) +
    labs(title = "Tempo Changes",
       subtitle = "How Tempo Changed Over The Years",
       caption = "Data source: Spotify pure rock and roll playlist ")

Major Versus Minor

Lastly i decided to compare the popularity of songs based on the mode_name variable (major or Minor). The popularity of modes varies but as I guessed before more than half of the songs with high popularity score are in minor scales this could be because musicians favor minor sound more in most cases. The plot below was made with geom_density() and few other useful functions such as scale_x_continuous() and theme() to manipulate my data based on the way I want it.

  ggplot(song_data) +
  geom_density(aes(x = track_popularity,
               fill = mode_name),
               position = "fill") +
  
    labs(title = "Major Vs Minor",
       subtitle = "A Plot About The corolation Of Song Mode And Song Popularity",
       x = "Populariy ",
       y = "Precentage",
       caption = "Data source: Spotify pure rock and roll playlist ") +
    scale_x_continuous(limits = c(0, 80),
                     breaks = seq(0, 80, 20)) +
  
  guides(colour = "none") +
  
  
theme(panel.background = element_rect(fill = "#f5f5f0")) 

Conclusion

In this assignment I tried to demonstrate how music has changed and evolved over the years with some visualizations using ggplot2 and gganimate. I used this playlists as it has a huge range of songs from different decades. I mainly focused on changes in a few fundamental music aspects such as song length, loudness and tempo of songs. What I have learned from plots above is that today’s music tends to be more loud, sometimes shorter and higher in tempo compared to music from past decades. I was also curious about how music mode (major or minor) effects the popularity scores of a song and it turns out that music in minor key is more popular.

Thanks for viewing my HTML, This program was last knitted on 2022-05-18 :-)